package TUILayer;
import java.util.Scanner;
/**
* This is a user interface and the main menu for this application.
* 
* @author (gruppe 1)
* @version (17.12.2012)
*/
public class MainMenuUI
{
/**
* Constructor for objects of class MainMenuUI
*/
public MainMenuUI()
{
}

/**
* Denne menu viser mainmenu
*/
public void start()
{
boolean exit = false;
while(!exit)
{
int choise = writeMainMenu();
switch(choise)
{
case 1:
print("case");
startKunde();
break;
case 2:
startOrdre();
break;
case 3:
print("Tak for at bruger denne applikation");
exit = true;
break;
default:
break;
}
}
}

/**
* Denne metoder viser en menu og venter på at der er noget der bliver registreret.
* 
* @returner valget som en int.
*/
private int writeMainMenu()
{
clr();
print(" *** Hoved Menu ***");
print(" (1) KundeBase");
print(" (2) SalgsModul");
print(" (4) Afslut");
print("\n Foretag din beslutning: ");

boolean exit = false;
int choise = 0;
while(!exit)
{
try
{
Scanner keyboard = new Scanner(System.in);
choise = keyboard.nextInt();
exit = true;
}
catch(Exception e)
{
print("Ugyldigt valg, prÃ¸v igen");
}
}
return choise;
}

/**
* Denne menu starter KundeBase
*/
private void startKunde()
{
KundeUI kundUI = new KundeUI();
kundUI.start();
}

/**
* Denne menu starter håndtering af ordre.
*/
private void startOrdre()
{
OrdreUI ordreUI = new OrdreUI();
ordreUI.start();
}

/**
* Denne metode pringer String str ud.
* 
* @param str A String bliver printed
*/
private void print(String str)
{
System.out.println(str);
}

/**
* Denne metoder resetter menuen.
*/
private void clr()
{
print("\f");
}
}